<#include "/common/_layout.html">
<#assign pageJavascript>
<script type="text/javascript">
var delit = function(obj){
	var tr = $(obj).parent().parent("tr").attr("id");
	var id = tr.replace("tr_","");
	listPage.deleteTr(tr,id);
};
$(function(){
	listPage.config = {listUrl:"/admin/user/userdeviceProfile/${userid!}",delUrl:"/admin/user/userdeviceDel"};
	listPage.showlist = function(data){
		if(data.list == undefined) return false;
		$("#showlist").empty();
		$.each(data.list, function (i, row) {
			var stat = ">未激活";
			if(row.stat==1){ stat = "class='warning'>未联网"; }
			else if(row.stat==2){ stat = "class='success'>已联网";}
			var str = '<tr id="tr_'+row.id+'"><td>'+row.deviceid+'</td><td>'+null2blank(row.sn)+'</td><td>'+null2blank(row.udname)+'</td><td '
				+stat+'</td><td>'+(row.btype=='8'?'机主':'普通用户')+'</td><td>'+row.bindtime+'</td><td>'
				+'<button class="btn btn-xs btn-danger" onclick="delit(this)">删除</button></td></tr>';
			$("#showlist").append(str);
		});
		$("#page").page({total:data.totalRow,currentpage:data.pageNumber,gopage:listPage.gopage,pagesize:data.pageSize});
	};
	$("#querybtn").click(function(){
		listPage.gopage(10,1);
	});
	$("#querybtn").click();	
});
</script>
</#assign>
<#assign pageCss>
<style type="text/css">
</style>
</#assign>
<@layout pageTitle="用户设备列表" pageJavascript=pageJavascript pageCss=pageCss>		
<br/>
<h3 class="page-header">用户设备列表</h3>
<div class="panel panel-default">
  <div class="panel-body filter">
	<div class="form-inline">
		<div class="form-group">
			<label for="sn">SN码：</label> 
			<input type="text" class="form-control" id="sn" data-rule="like">
			<label for="mac">mac地址：</label> 
			<input type="text" class="form-control" id="mac" data-rule="like">
	    	<label>绑定时间：</label>
		    <input class="form-control" style="width:120px" onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd'})" type="input" data-rule="ge" id="start_t.bindtime" >～
			<input class="form-control" style="width:120px" onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd'})" type="input" data-rule="dtle" id="end_t.bindtime" >
			<button id="querybtn" class="btn btn-default">查询</button>
			<a href="/admin/user/list" class="btn btn-warning">返回</a>
		</div>
	</div>
  </div>
</div>
<table class="table table-bordered table-hover table-striped">
	<thead>
		<tr>
			<th>mac地址</th>
			<th>SN码</th>
			<th>备注名</th>
			<th>设备状态</th>	
			<th>绑定类型</th>		
			<th>绑定时间</th>		
			<th>操作</th>
		</tr>
	</thead>
	<tbody id="showlist"></tbody>
</table>
<nav><ul id="page" class="pagination"></ul></nav>
</@layout>